package dayOOP0714;

import java.util.Objects;

public class Stud  implements  Comparable{
    private  int   stuId;
    private  String name;
    private  char   sex;
    private  double height;

    public int compareTo(Object o) {
        Stud  s=(Stud)o;
        return (int)( s.height*10  -  this.height*10);
    }


    public Stud() { }

    public Stud(int stuId, String name, char sex, double height) {
        this.stuId = stuId;
        this.name = name;
        this.sex = sex;
        this.height = height;
    }

    public int getStuId() {
        return stuId;
    }

    public void setStuId(int stuId) {
        this.stuId = stuId;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public char getSex() {
        return sex;
    }

    public void setSex(char sex) {
        this.sex = sex;
    }

    public double getHeight() {
        return height;
    }

    public void setHeight(double height) {
        this.height = height;
    }

    //toString


    public String toString() {
        return "Stud{" +
                "name='" + name + '\'' +
                ", height=" + height +
                '}';
    }

    public int  hashCode(){
        return  Objects.hash(stuId, name,sex,height);
    }


    //equals
    public boolean   equals(Object  o){
        super.equals(o);
        //1.  用  ==  ,相同返回true
        if(this==o){return true;}
        //2.  类型如果不同返回false
        if(o==null ||  ! (o  instanceof Stud) ){
            return  false;
        }
        //3. 比较成员变量
        Stud  o2=(Stud) o;
        boolean  rs= Objects.equals(this.name,o2.name) && this.stuId==o2.stuId;
        return  rs;
    }




    public static void main(String[] args) {
       Stud s1=new Stud();
       Stud s2=new Stud();
        System.out.println(s1.equals(s2));
    }


}


//Teacher :  名字，  课程， 工资
//ClassRoom :  num,  area,  seats